home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-in_the_mag-
/
banging_the_metal
/
cd32
/
nvtools
/
setnv.mod
< prev
next >
Wrap
Text File
|
1999-11-30
|
2KB
|
82 lines
MODULE SetNV;
(*
$StackChk-
$RangeChk-
$NilChk-
$OvflChk-
$ReturnChk-
$CaseChk-
*)
IMPORT
y := SYSTEM,
(* Interfaces *)
d := Dos,
e := Exec,
nv := NonVolatile,
str := Strings;
CONST
template = "AN=APPNAME/A,IN=ITEMNAME/A,KR=KILLREQUESTER/S,DATA/A/F"
"\o$VER: SetNV.mod 1.0 (30.09.95)";
TYPE
Args = STRUCT (as :d.ArgsStruct)
appName :d.ArgString;
itemName :d.ArgString;
killReq :d.ArgBool;
data :d.ArgString;
END;
VAR
args :d.RDArgsPtr;
argv :Args;
size :LONGINT;
info :nv.NVInfoPtr;
err :LONGINT;
BEGIN
IF nv.base=NIL THEN
d.PrintF("No nonvolatile.library!\n");
HALT(20);
END;
args := d.ReadArgs(template, argv, NIL);
IF args=NIL THEN
IF d.PrintFault(d.IoErr(), "SetNV") THEN END;
HALT(20);
END;
info := nv.GetNVInfo(argv.killReq);
size := str.Length(argv.data^) DIV 10 + 1;
d.PrintF("Size: %ld\n", size);
IF size>info.maxStorage THEN
d.PrintF("String too long (or NVRAM too small :)\n");
HALT(20);
END;
err := nv.StoreNV(argv.appName^, argv.itemName^, y.VAL(nv.DataPtr, argv.data), size, argv.killReq);
CASE err OF
0:
|nv.errBadName:
d.PrintF("App or itemname is illegal\n");
HALT(20);
|nv.errWriteProt:
d.PrintF("NVRAM is write protected!\n");
HALT(20);
|nv.errFail:
d.PrintF("NVRAM is full or write protected!\n");
HALT(20);
|nv.errFatal:
d.PrintF("FATAL Error!\nPossible loss of data.");
HALT(20);
END;
CLOSE
d.FreeArgs(args);
nv.FreeNVData(y.VAL(nv.DataPtr, info));
END SetNV.